import { ListPage } from "custom/index";
import { getCustomerServiceList } from './api'
import { becomeRegularStatusOptions, onDutyStatusOptions } from './constant'
import { editDialog } from './dialog'
import { onClearCustomerServiceGroup, changeBlacklist, changeWhitelist } from './action'
import Blacklist from './components/Blacklist.vue'
import Whitelist from './components/Whitelist.vue'

const page = new ListPage('CustomerServiceList');

page
  .api(getCustomerServiceList)
  .useTabs()
    .setProp('onDutyStatus')
    .setDefualt('')
    .addTab({ value: '', label: '全部' })
    .addTab({ value: 1, label: '在职' })
    .addTab({ value: 0, label: '离职' })
    .end()
  .useSearch()
    .addInputItem('keyword', '客服名称/客服ID/客服花名/客服工号', '')
    .addItem({ prop: 'userId', label: '客服ID ' })
    .addItem({ prop: 'name', label: '客户名称' })
    .addItem({ prop: 'flowerName', label: '客服花名' })
    .addItem({ prop: 'no', label: '客服工号' })
    .addSelect({ prop: 'becomeRegularStatus', label: '转正状态' }, becomeRegularStatusOptions)
    .addDictSelect({ prop: 'customPostType', label: '客服岗位类别' }, 'customPostType')
    .end()
  .useTable()
    .useIndexColumn().end()
    .useColumn('groupNo').label('编队').sortable().end()
    .useColumn('name').label('姓名').minWidth(140).end()
    .useColumn('flowerName').label('花名').minWidth(100).end()
    .useColumn('mobile').label('手机号').minWidth(120).end()
    .useColumn('no').label('工号').sortable().end()
    .useColumn('sex').label('性别').sortable().end()
    .useColumn('pestName').label('类型').sortable().end()
    .useColumn('customGroupName').label('分组').minWidth(200).sortable().end()
    .useColumn('customPostTypeName').label('岗位类别').minWidth(200).end()
    .useColumn('entryDate').label('入职时间').minWidth(120).sortable().end() 
    .useEnumColumn('onDutyStatus', onDutyStatusOptions).label('在职状态').end()
    .useEnumColumn('becomeRegularStatus', becomeRegularStatusOptions).label('转正状态').end()
    .useColumn('becomeRegulardDate').label('转正时间').end()
    .end()
  .usePagination()
    .end()
  .useAuthButton()
    .useItem('export').content('导出数据').exportExcel().end()
    .end()
  .useAuthColumn({ width: 120, label: '黑名单' })
    .useItem('blacklist').setComponent(Blacklist).action(changeBlacklist).end()
    .end()
  .useAuthColumn({ width: 120, label: '白名单' })
    .useItem('whitelist').setComponent(Whitelist).action(changeWhitelist).end()
    .end()
  .useAuthColumn({ width: 140 })
    .useItem('edit').content('编辑').editRow(editDialog).end()
    .useItem('clear').content('清空编组').action(onClearCustomerServiceGroup).end()
    .end()

export default page
